$(function () {
    $.ajax({
        type: 'POST',
        async: false,
        url: '/zjj/queryAllProductionPlans.action',
        contentType: 'application/json;charset=utf-8',
        success: function (result) {
            $.each(result.data, function (i, v) {
                let tr = $("<tr></tr>")
                    .append("<td>" + v.applyId + "</td>")
                    .append("<td>" + v.register + "</td>")
                    .append("<td>" + v.designer + "</td>")
                    .append("<td>" + v.registerTime + "</td>")
                    .append("<td>" + v.remark + "</td>")
                    .append("<td>" + (v.checkTag=='S001-0'?'等待':v.checkTag=='S001-1'?'通过':'未通过') + "</td>")
                    .append("<td><button value='" + v.applyId + "' data-toggle=\"modal\" data-target=\"#myModal\" class='btn btn-info' onclick='viewCurrentProductionPlan(this)'>查看</button></td>");

                $("#tbodyCommodity").append(tr);
            })
            jQuery.getScript("../js/datatables.init.js")
        }
    })
})
function viewCurrentProductionPlan(e) {
    $.ajax({
        type: 'POST',
        async: false,
        url: '/zjj/queryTheCurrentProductionPlan.action',
        contentType: 'application/json;charset=utf-8',
        data: $(e).val(),
        success: function (result) {
            $("#tbody").html('')
            let curren = result.data[0];
            $("#planOrderNumber").val(curren.applyId)
            $("#registerPerson").val(curren.register)
            $("#checkInTime").val(curren.registerTime)
            $("#reviewTime").val(curren.checkTime)
            $("#reviewer").val(curren.checker)
            $("#auditOpinion").val(curren.checkSuggestion)
            $("#auditResults").text(curren.checkTag=='S001-0'?'等待':curren.checkTag=='S001-1'?'通过':'未通过')
            $.each(result.data, function (i, v) {
                let tr = $("<tr></tr>")
                    .append("<td>" + v.productId + "</td>")
                    .append("<td>" + v.productName + "</td>")
                    .append("<td>" + v.productDescribe + "</td>")
                    .append("<td>" + v.amount + "</td>")
                    .append("<td>" + v.constPrice + "</td>");
                $("#tbody").append(tr)
            })
        }
    })
}